<?php
class PM_a
{
    public static function __index( $room_id , $user_id , $card_number , $db_connect ){
        //取出房间信息
        $room_info  = $db_connect->select('*')->from('tt_room')->where("room_id= '". $room_id ."' ")->row();
        //取出该房间对应的当前申请胡牌的用户牌面信息
        $card_info  = $db_connect->select('*')->from('tt_room_card')->where("uid = '". $user_id ."' and jid = '". $room_info['room_js'] ."' and rid= '". $room_id ."' ")->row();
        //取出该用户原本胡息
        $default_huxi = PHZ_Tools::__get_user_xpAndKanzi_Huxi( $room_id , $user_id );
        //自摸的畏提胡，需要进行基础牌更换操作
        $card_info['sp']   = explode(",",$card_info['sp']);
        $temp_cardnumber   = $card_info['sp'][0];
        unset( $card_info['sp'][0] );
        $card_info['sp']  = implode(",",$card_info['sp']);
        $canHu = PHZ_CanHu::__isCan_Hu_Pai( $default_huxi, $card_info['sp'], $temp_cardnumber , $temp_cardnumber , $room_info );//胡牌判断
        //可以胡的情况下，进行自摸的数据结算
        if( $canHu['canHu'] == true ){
            PHZ_Scoring::__game_Single_END( $room_info , $canHu['huXi'] , $user_id , 0 , $card_number , 2 , $db_connect );//自摸
        }
        return true;
    }
}